<?php
  require_once("include/fns.inc");
  if ($_POST['id']!='' && $_POST['user_name']!='') {
    insert_user_into_db($_POST['id'], $_POST['s_id'], $_POST['login'], $_POST['password'], $_POST['type'], $_POST['user_name'], $_POST['duty'], $_POST['phone'], $_POST['email']);
    /*
    $link = mysql_connect('', 'admin_xbq', 'nihao')
        or die('Could not connect: ' . mysql_error());
    echo "Connected successfully\n";

    mysql_query('use test;');
    $sql = 'INSERT INTO `user` (`user_ID`, `sr_ID`, `login`, `password`, 
    `user_type`, `user_name`, `user_duty`, `phone`, `email`) VALUES (\''.$_POST['id'].'\',
    \''.$_POST['s_id'].'\', \''.$_POST['login'].'\', \''.$_POST['password'].' \', \''.$_POST['type'].'\',
    \''.$_POST['user_name'].'\', \''.$_POST['duty'].'\', \''.$_POST['phone'].'\', \''.$_POST['email'].'\');';
    $result = mysql_query($sql) or die('Query failed: ' . mysql_error());
    mysql_close($link);
    */
    echo 'Please create next teacher.';
  }
?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>?sr_id=<?php echo $_GET['sr_id'];?>" method="post">
  <table align="center" width="400">
    <tr>
      <td class="style3">User ID:</td>
      <td align="right" class="style3"><input width="100" name="id" type="text" /></td>
    </tr>
    <tr>
      <td class="style3">Staff room ID:</td>
      <td align="right" class="style3">
        <input width="100" name="s_id" type="text" value="<?php echo $_GET['sr_id']; ?>" /></td>
    </tr>
    <tr>
      <td class="style3">User name:</td>
      <td align="right" class="style3"><input name="user_name" type="text" /></td>
    </tr>
    <tr>
      <td class="style3">Login:</td>
      <td align="right" class="style3"><input name="login" type="text" /></td>
    </tr>
    <tr>
      <td class="style3">Password:</td>
      <td align="right" class="style3"><input  name="password" type="text" /></td>
    </tr>
    <tr>
      <td class="style3">User type:</td>
      <td align="right" class="style3">        
        <select name="type">
          <option value="t"> Teacher </option>
          <option value="s"> Head of staff room </option>
          <option value="d"> Head of department </option>
          <option value="r"> Rector </option>
        </select>
      </td>
    </tr>
    <tr>
      <td class="style3">User duty:</td>
      <td align="right" class="style3">
        <select name="duty">
          <option value="Professor"> Professor </option>
          <option value="Associate professor"> Associate professor </option>
          <option value="Old teacher"> Old teacher </option>
          <option value="Assistant"> Assistant </option>
        </select>
      </td>
    </tr>
    <tr>
      <td class="style3">User phone:</td>
      <td align="right" class="style3"><input name="phone" type="text" /></td>
    </tr>
    <tr>
      <td class="style3">User e-mail:</td>
      <td align="right" class="style3"><input name="email" type="text" /></td>
    </tr>
    <tr>
      <td class="style3" align="right"><input name="add" type="button" value="Reset" /></td>
      <td align="left" class="style3"><input name="add" type="submit" value="Add next" /></td>
    </tr>
  </table>
</form>
